package com.yuanduan.mplus.view;

import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.cj.framework.app.BaseActivity;
import com.yuanduan.mplus.R;
import com.yuanduan.mplus.config.Config;

/**
 * Created by cj on 2016/6/18.
 * Email:781806481@qq.com
 * 资讯界面
 */
public class Consult1Activity extends BaseActivity{
    private WebView webView;
    private Toolbar toolbar;

    @Override
    protected void findId() {
        webView= (WebView) findViewById(R.id.consult1_webView);
    }

    @Override
    protected void logic() {
        toolbar= (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("资讯");
        toolbar.setNavigationIcon(R.mipmap.back_arrow_black);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Consult1Activity.this.finish();
            }
        });
        WebSettings settings=webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.loadUrl(Config.URL+Config.CONSULT);
        webView.setWebViewClient(new WebViewClient());
    }

    @Override
    protected int setLayout() {
        return R.layout.activity_consult1;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode==KeyEvent.KEYCODE_BACK&&webView.canGoBack()){
            webView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode,event);
    }
}
